<?
    Principio_Library_Common::printErrorsAndMsg($this);

    switch ($this->level)
    {
        case 1:
            echo "<ul>".$this->partial("menu/partial.companies.phtml", array("companies" => $this->companies))."</ul>";
            break;

        case 2:
            if ($this->model_company->isPool())
                echo $this->partial("menu/partial.companies.phtml", array("companies" => $this->companies, "pool_id" => $this->model_company->getID()));

            echo $this->partial("menu/partial.types.phtml", array("types" => $this->types, "model_company" => $this->model_company));
            break;

        case 3:
            echo $this->partial("menu/partial.spa.phtml", array("spaes" => $this->spaes, "company_id" => $this->company_id, "type_id" => $this->type_id));
            break;

        case 4: // Navigate to the Company
            echo "<ul>";
            $result = $this->partial("menu/partial.companies.phtml", array("companies" => $this->companies));

            if ($this->parent_id != -1)
            {
                $result .= $this->partial("menu/partial.types.phtml", array("types" => $this->types, "model_company" => $this->model_company_pool));
                $result = $this->partial("menu/partial.companies.phtml", array("companies" => $this->main_companies, "expand_company_id" => $this->parent_id, "expand" => $result));
            };

            echo $result."</ul>";
            break;


        case 5: // Navigate to the SPA
            echo "<ul>";

            $result = $this->partial("menu/partial.types.phtml", array(
                                                                            "types" => $this->company_types,
                                                                            "model_company" => $this->model_company,
                                                                            "expand_type_id" => $this->type_id,
                                                                            "expand" => $this->partial("menu/partial.spa.phtml", array("spaes" => $this->spaes, "company_id" => $this->model_company->getID(), "type_id" => $this->type_id))));

            if (($this->model_company->isCompanyInPool()) || ($this->model_company->isPool()))
            {
                if ($this->model_company->isCompanyInPool())
                {
                    $result = $this->partial("menu/partial.companies.phtml", array("companies" => $this->companies, "expand_company_id" => $this->model_company->getID(), "expand" => $result, "pool_id" => $this->model_company->getOwnerPoolID()));
                    $result .= $this->partial("menu/partial.types.phtml", array("types" => $this->types, "model_company" => $this->model_company_pool));
                    $result = $this->partial("menu/partial.companies.phtml", array("companies" => $this->main_companies, "expand_company_id" => $this->model_company->getOwnerPoolID(), "expand" => $result));
                }
                else
                {
                    $result = $this->partial("menu/partial.companies.phtml", array("companies" => $this->companies, "pool_id" => $this->model_company->getOwnerPoolID())).$result;
                    $result = $this->partial("menu/partial.companies.phtml", array("companies" => $this->main_companies, "expand_company_id" => $this->model_company->getID(), "expand" => $result));
                };

            }
            else
                $result = $this->partial("menu/partial.companies.phtml", array("companies" => $this->companies, "expand_company_id" => $this->model_company->getID(), "expand" => $result));

            echo $result."</ul>";
            break;
    } // switch ($this->level)
?>